<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>管理收货地址</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/address-list.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">管理收货地址</h1>
		</header>
		<div class="mui-content" style="padding-top: 30px;padding-bottom: 30px;">
			<ul class="mui-table-view" id="address-list">
				<li class="mui-table-view-cell" :class="{'active-bg-color':a.defaultAddress==1}" v-for="a in list" @click="opne_updateadress_page(a.id)">
					<span style="float: left;">收货人:{{a.receivePerson}}</span>
					<span style="float: right;">{{a.receivePhone}}<i v-show="a.defaultAddress==1" class="mui-icon mui-icon-checkmarkempty"></i></span>
					<p style="clear: both;" :class="{'actice-text-color':a.defaultAddress==1}">{{a.province}}{{a.city}}{{a.area}}{{a.detailedAddress}}</p>
				</li>
			</ul>
		</div>
		<footer class="mui-bar mui-bar-tab" style="height: 35px;">
			<button class="addBtn" onclick="opne_add_adress_page()">新增收货地址</button>
		</footer>

		<script src="../js/mui.min.js"></script>
		<script type="text/javascript" src="../js/const.js"></script>
		<script type="text/javascript" src="../js/request.js"></script>
		<script type="text/javascript" src="../js/address_service.js"></script>
		<script type="text/javascript" src="../js/vue.min.js"></script>
		<script type="text/javascript" src="../js/jquery-1.8.3.min.js" ></script>
		<script type="text/javascript">
			mui.init()

			//vue对象
			var address = new Vue({
				el: '#address-list',
				data: {
					list: [],
				},
				methods: {
					//打开详情页面
					opne_updateadress_page: function(addressId) {
						mui.openWindow({
							id: 'address-add.html',
							url: 'address-add.html',
							extras: {
								type: 'update', //修改
								addressId: addressId
							}
						});
					}
				}

			});
	

			mui.plusReady(function() {
				var self = plus.webview.currentWebview();
				//添加hide事件
				self.addEventListener('hide', function(e) {
					window.scrollTo(0, 0); //滚到顶部
					data_detail.resetData(); //数据重置
				}, false);
				plus.nativeUI.showWaiting('加载中', {
					width: '100px',
					height: '100px'
				});
				//获取接口数据
				var res = addressService.my_address_list();
				address.list = res.data;
				plus.nativeUI.closeWaiting();

			});

			function opne_add_adress_page() {
				mui.openWindow({
					id: 'address-add.html',
					url: 'address-add.html',
					extras: {
						type: 'add' //修改
					}
				});
			}

			window.addEventListener('refresh', function(e) {
				//获取接口数据
				var res = addressService.my_address_list();
				address.list = res.data;

			})
		</script>
	</body>

</html>